package fr.enssat.embeddedsoft.projet.sumo.abouzidi.mndiaye;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.util.AttributeSet;
import android.view.View;

public class AccelView extends View {

	private Cercle accelorometre;
	
	public AccelView(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);
		init();
	}

		
	public AccelView(Context context, AttributeSet attrs) {
		super(context, attrs);
		init();
	}

	
	public AccelView(Context context) {
		super(context);
		init();
	}
	
	public void init(){		
		accelorometre = new Cercle(50,Color.WHITE);
		
	}
	
	public void setAccelPlace(int x, int y) {
		accelorometre.setX(x-10);
		accelorometre.setY(y);
		invalidate();		
}
	
	@Override
	protected void onSizeChanged(int w, int h, int oldw, int oldh) {
		// TODO Auto-generated method stub
		super.onSizeChanged(w, h, oldw, oldh);
		accelorometre.setX(w/2);
		accelorometre.setY(h/2);
	}
	
	
	@Override
	protected void onDraw(Canvas canvas) {
		// TODO Auto-generated method stub
		super.onDraw(canvas);
		accelorometre.draw(canvas);
	}
	
	

}

